package com.soecode.wxtools.util.http;

import com.soecode.wxtools.exception.WxErrorException;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;

import java.io.IOException;

public class SimplePostRequestExecutor implements RequestExecutor<String, String> {
    @Override
    public String execute(CloseableHttpClient httpclient, String uri, String params)
            throws WxErrorException, IOException {
        HttpPost httpPost = new HttpPost(uri);

        if (params != null) {
            httpPost.setEntity(new StringEntity(params, "UTF-8"));
        }

        return validate(httpclient, httpPost);
    }

}
